home *** CD-ROM | disk | FTP | other *** search
Wrap
<XST Filename='details.xst' Description='Output single address from Pilot database to HTML or Plaintext. Returns the first record from the addressbook matching either the given first name or surname' Author='David Ball/Philip Allen' Version='2.0' Date='12 April 1999' Copyright='© 1999 DecisionSoft Limited' XMLscript='1.0' Ref='details' debug='' __maxCR="2" ><_if test=" \ENV\REQUEST_METHOD.__exists" >Content-type: text/html </_if> <!-- We need the "Content-type: text/html" to be on the first output line followed by two carriage returns, if we're running in cgi Note the 'double backslash' used instead of the single backslash. Always use double backslash when describing DOS/Windows directory paths. --> <!-- YOU NEED TO CONFIGURE THESE --> # $\.appsRoot := "..\\pilot\\" # # $\.datName := "sample.dat" # <!-- If we're coming in from the command line, arguments with spaces in will have quotes around them (because DOS batch files are lame), which we don't want. So we need to get rid of them... --> <_if test="\ENV\FIRSTNAME.__exists"> <then> <barney __mode="hide"> <fred __maxCR="0"><_filter find='\"' replace=''># \ENV\FIRSTNAME #</_filter></fred> </barney> # \ENV\FIRSTNAME := $barney\fred # </then> </_if> <_if test="not( \CGI\surname.__exists) and (\ENV\SURNAME.__exists)"> # \CGI\surname := \ENV\SURNAME # </_if> <_if test="not( \CGI\firstname.__exists) and (\ENV\FIRSTNAME.__exists)"> # \CGI\firstname := \ENV\FIRSTNAME # </_if> <_if test=" \ENV\REQUEST_METHOD.__exists" > <then> # $\.context := "cgi" # </then> <else> # $\.context := "cmdline" # </else> </_if> <_if test="0"> <!-- Defaults used for debugging CGI operation --> # \CGI\surname := "Clinton" # # \CGI\firstname := "William" # # $\.context := "cgi" # # $\.fileOut := "1" # </_if> # \.context := $\.context # <!-- Set global attributes --> # $.cellColor := "yellow" # # $.mainColor := "lightblue" # <!-- Define the system command --> # $\.cmd := $\.appsRoot 'loadbook ' $\.appsRoot $\.datName # # $\.sysCmd := $\.cmd '> c:\\temp\\CGItmp.txt' # <!-- The system command is piped to file to make it work with httpd. --> <_eval result="data"> <_filter find='\#' replace='' > <Pilot > <_system command="# $\.sysCmd #"/> <_echo file="c:\temp\CGItmp.txt" /> </Pilot> </_filter> </_eval> <_if > Debug information: incoming data -# \Pilot #- </_if> <!-- Define the templates we're going to run --> <_template name="DisplayOneHTML" > <_foreach object="AddressRecord" > <_if test="not( \CGI\surname.__exists) and (not( \CGI\firstname.__exists) or (\CGI\firstname == FirstName))"> # \CGI\surname := LastName # </_if> <_if test="not( \CGI\firstname.__exists) and (\CGI\surname == LastName)"> # \CGI\firstname := FirstName # </_if> <_if test="(LastName == \CGI\surname) and (FirstName == \CGI\firstname)"><then> <HTML> <HEAD> <TITLE>XML address display</TITLE> </HEAD> <BODY BGCOLOR="ffffff"> <CENTER> <TABLE CELLPADDING="10"> <TR> <TD ALIGN="left" VALIGN="bottom"> <IMG SRC="images/xmlscript.jpg" ALT="XML Script" /> </TD> <TD BGCOLOR="#$.mainColor#" ALIGN="center"> <TABLE CELLPADDING="5"> <TR> <TD ALIGN="left" VALIGN="top"><B>Name</B></TD> <TD BGCOLOR="# $.cellColor #">#FirstName# #LastName#</TD> </TR> <TR> <TD ALIGN="left" VALIGN="top"><B>Title</B></TD> <TD BGCOLOR="#$.cellColor#">#Title#</TD> </TR> <TR> <TD ALIGN="left" VALIGN="top"><B>Address</B></TD> <TD BGCOLOR="#$.cellColor#">#Address#<BR /> #City# #State# #Zipcode#</TD> </TR> <TR> <TD ALIGN="left" VALIGN="top"><B>Email</B></TD> <TD BGCOLOR="#$.cellColor#"><A HREF="#'mailto:' Email#">#Email#</A></TD> </TR> <TR> <TD ALIGN="left" VALIGN="top"><B>Work</B></TD> <TD BGCOLOR="#$.cellColor#">#Phone#</TD> </TR> <TR> <TD ALIGN="left" VALIGN="top"><B>Home</B></TD> <TD BGCOLOR="#$.cellColor#">#Home#</TD> </TR> <TR> <TD ALIGN="left" VALIGN="top"><B>Fax</B></TD> <TD BGCOLOR="#$.cellColor#">#Fax#</TD> </TR> </TABLE> </TD> </TR> </TABLE> </CENTER> </BODY> </HTML> </then> </_if> </_foreach> </_template> <_template name="DisplayOnePlain"> <_foreach object="AddressRecord" > <_if test="not( \CGI\surname.__exists) and (not( \CGI\firstname.__exists) or (\CGI\firstname == FirstName))"> # \CGI\surname := LastName # </_if> <_if test="not( \CGI\firstname.__exists) and (\CGI\surname == LastName)"> # \CGI\firstname := FirstName # </_if> <_if test="(LastName == \CGI\surname) and (FirstName == \CGI\firstname)"> XML address display Name: #FirstName# #LastName# Title: #Title# Address: #Address# #City# #State# #Zipcode# Email: #Email# Work: #Phone# Home: #Home# Fax: #Fax# </_if> </_foreach> </_template> <!-- Tie the template to the data --> <_method object="Pilot" template="DisplayOneHTML" context="cgi" /> <_method object="Pilot" template="DisplayOnePlain" context="cmdline" /> <!-- Process the data --> <_if test="$\.fileOut"> <then> <_output type="file" mode="replace" name="# '../output/' $\.Ref '.out' #" __maxCR="1"><_process object="\Pilot" /></_output> <_output type="file" mode="replace" name="# '../output/' $\.Ref '.dif' #" __maxCR="1"> <_system __maxCR="1" command="# 'diffHtml.bat ' $\.Ref #" /></_output> </then> <else> <_if test="((\CGI\surname.__exists) and (\CGI\firstname.__exists) and not( \Pilot\AddressRecord{( LastName == \CGI\surname ) and ( FirstName == \CGI\firstname )})) or ((\CGI\surname.__exists) and not( \CGI\firstname.__exists) and not( \Pilot\AddressRecord{( LastName == \CGI\surname)})) or (not( \CGI\surname.__exists) and (\CGI\firstname.__exists) and not( \Pilot\AddressRecord{( FirstName == \CGI\firstname)}))"> <then> <_if test="$.context == 'cgi'"> <then> <HTML> <HEAD> <TITLE>XML address display</TITLE> </HEAD> <BODY BGCOLOR="ffffff"> <H1 ALIGN="Left">No Matches Found</H1> </BODY> </HTML> </then> <else> No Matches found. </else> </_if> </then> <else> <_process object="\Pilot" /> </else> </_if> </else> </_if> </XST>